package com.ruoyi.web.controller.wifi;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.WfDetail;
import com.ruoyi.system.service.IWfDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * WIFI信息Controller
 *
 * @author ruoyi
 * @date 2024-08-10
 */
@RestController
@RequestMapping("/system/wifi")
public class WfDetailController extends BaseController {
    @Autowired
    private IWfDetailService wfDetailService;

    /**
     * 查询WIFI信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfDetail wfDetail) {
        startPage();
        List<WfDetail> list = wfDetailService.selectWfDetailList(wfDetail);
        return getDataTable(list);
    }

    /**
     * 导出WIFI信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:export')")
    @Log(title = "WIFI信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfDetail wfDetail) {
        List<WfDetail> list = wfDetailService.selectWfDetailList(wfDetail);
        ExcelUtil<WfDetail> util = new ExcelUtil<>(WfDetail.class);
        util.exportExcel(response, list, "WIFI信息数据");
    }

    /**
     * 删除WIFI信息
     */
    @PreAuthorize("@ss.hasPermi('system:detail:remove')")
    @Log(title = "WIFI信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{wfIds}")
    public AjaxResult remove(@PathVariable Long[] wfIds) {
        return toAjax(wfDetailService.removeByIds(Arrays.asList(wfIds)));
    }
}
